package cn.com.clearbus.entity.weChat.node;


import cn.com.clearbus.utils.UrlUtil;

public class UrlNode<E> implements Node<E> ,BuildModelViewSupport{

    private E e;
    private String url;
    private String modelView;
    private String appId;

    public UrlNode(E e,String url){
        this(e,url,"");
    }

    public UrlNode(E e,String url,String appId){
        this.e = e;
        this.url = url;
        this.appId = appId;
    }

    public String getUrl(){
        return this.url;
    }

    @Override
    public String toString() {
        return e.toString();
    }

    public String buildModelView(boolean authorize){
        if (!authorize) {
            modelView = UrlUtil.buildSimpleUrl(this);
        } else {
            modelView = UrlUtil.buildBaseAuthorizeUrl(this,appId);
        }
        return modelView;
    }

    @Override
    public String getModelView() {
        return modelView;
    }
}
